﻿<Window x:Class="TwitCast.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="clr-namespace:WPF.Extensions;assembly=WPF.Extensions"
        Title="TwitCast" Height="400" Width="640" MaxHeight="400"
        Loaded="Window_Loaded" ShowInTaskbar="False" Topmost="True" WindowStyle="None" Background="Transparent" AllowsTransparency="True"
        Name="twitWindow"
        Icon="twitter.ico">
    <Window.Resources>
        <DataTemplate x:Key="TweetTemplate">
            <Border Background="#FFFFFFFF" BorderThickness="1" CornerRadius="5" BorderBrush="#FF000000" Margin="5,5,5,5" Height="60" Opacity="1">
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <TextBlock Text="{Binding Path=User.Name}" FontWeight="Bold" Foreground="Black" />
                        <TextBlock Text=" at " Foreground="Black" />
                        <TextBlock Text="{Binding Path=CreatedAt}" Foreground="Black" />
                    </StackPanel>
                    <TextBlock Text="{Binding Path=Text}" TextWrapping="Wrap" Height="40" Foreground="Black" />
                </StackPanel>
            </Border>
        </DataTemplate>
        <ItemsPanelTemplate x:Key="TweetPanel">
            <StackPanel Orientation="Vertical">
            </StackPanel>
        </ItemsPanelTemplate>
        <s:StatefulStoryboard x:Key="statefulOne" Target="{x:Reference Name=tweetWindow}">
            <Storyboard s:StatefulStoryboard.IsInitial="True" s:StatefulStoryboard.StateName="Hidden">
                <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.4" Duration="0:0:0.2" />
                <DoubleAnimation Storyboard.TargetProperty="(Border.RenderTransform).(TranslateTransform.Y)" To="-370" Duration="0:0:0.2" BeginTime="0:0:0.2" />
            </Storyboard>
            <Storyboard s:StatefulStoryboard.StateName="NewTweet">
                <DoubleAnimation Storyboard.TargetProperty="(Border.RenderTransform).(TranslateTransform.Y)" To="-295" Duration="0:0:0.2" />
                <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
            </Storyboard>
            <Storyboard s:StatefulStoryboard.StateName="AllTweets">
                <DoubleAnimation Storyboard.TargetProperty="(Border.RenderTransform).(TranslateTransform.Y)" To="-20" Duration="0:0:0.2" />
                <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
            </Storyboard>
            <s:StatefulStoryboard.StateTransitions>
                <s:ValidStateTransitionFrom StateName="*">
                    <s:StateTransitionTo StateName="Hidden" />
                </s:ValidStateTransitionFrom>
                <s:ValidStateTransitionFrom StateName="Hidden">
                    <s:StateTransitionTo StateName="NewTweet" />
                    <s:StateTransitionTo StateName="AllTweets" />
                </s:ValidStateTransitionFrom>
                <s:ValidStateTransitionFrom StateName="NewTweet">
                    <s:StateTransitionTo StateName="AllTweets" />
                </s:ValidStateTransitionFrom>
            </s:StatefulStoryboard.StateTransitions>
        </s:StatefulStoryboard>
    </Window.Resources>
    <Grid>
        <Border CornerRadius="10" Background="#FFB2DFDA" Width="620" Height="360" Name="tweetWindow" MouseEnter="tweetWindow_MouseEnter" MouseLeave="tweetWindow_MouseLeave">
            <Border.RenderTransform>
                <TranslateTransform Y="0" />
            </Border.RenderTransform>
            <ScrollViewer Margin="3,10,10,10" Name="tweetsViewer">
                <ItemsControl Name="tweetsPresenter" ItemTemplate="{StaticResource TweetTemplate}" ItemsPanel="{StaticResource TweetPanel}" />
            </ScrollViewer>
        </Border>
    </Grid>
</Window>

